//標記:增加Treemap 至 viewcontroller 加入treemap viewclass
/*
 project中加入 
 TreemapViewCell.h  
 TreemapViewCell.m
 TreemapView.h
 TreemapView.m 
 */

#import <UIKit/UIKit.h>
#import "TreemapViewCell.h"

@protocol TreemapViewDataSource;
@protocol TreemapViewDelegate;

@interface TreemapView : UIView <TreemapViewCellDelegate> {
    id <TreemapViewDataSource> dataSource;
    id <TreemapViewDelegate> delegate;

    BOOL initialized;
}

@property (nonatomic, retain) id <TreemapViewDataSource> dataSource;
@property (nonatomic, retain) id <TreemapViewDelegate> delegate;

- (void)reloadData;

@end

@protocol TreemapViewDelegate <NSObject>

@optional

- (void)treemapView:(TreemapView *)treemapView touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)treemapView:(TreemapView *)treemapView touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)treemapView:(TreemapView *)treemapView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)treemapView:(TreemapView *)treemapView touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)treemapView:(TreemapView *)treemapView tapped:(NSInteger)index;
- (void)treemapView:(TreemapView *)treemapView updateCell:(TreemapViewCell *)cell forIndex:(NSInteger)index forRect:(CGRect)rect;

@end

@protocol TreemapViewDataSource <NSObject>

//Provides data for a TreemapView as a NSArray.
- (NSArray *)valuesForTreemapView:(TreemapView *)treemapView;

//Returns a cell object for the specified place. You need to create a TreemapViewCell and return it.
- (TreemapViewCell *)treemapView:(TreemapView *)treemapView cellForIndex:(NSInteger)index forRect:(CGRect)rect;

@optional
//Returns a separator width for the specified depth. If you don't need to change the width for the specified depth, return 0. The default separator width is 0.
- (CGFloat)treemapView:(TreemapView *)treemapView separatorWidthForDepth:(NSInteger)depth;


//Normally TreemapView separate two rectangles with calculating the areas, but if you want to separate two groups manually, return the index of the cells. If you don't need to change the separation position for the specified depth, return NSIntegerMax.

- (NSInteger)treemapView:(TreemapView *)treemapView separationPositionForDepth:(NSInteger)depth;

@end
